Reproducible Research II

Adam M. Wilson

September 2015

Overview

Questions from last week?

  • Got Git?

Homework Review

Today

Outline

  • More Git
  • More Markdown
  • Introduction to ggplot2()
  • Introduction to spatial data in R

Working with Git and GitHub

Branching

Git branches are

Commit to GitHub from within RStudio

Steps: 1. Stage 2. Commit (with a message) 3. Push

RMarkdown

RMarkdown

alt text

RMarkdown

alt text

RMarkdown

alt text

RMarkdown

alt text

RMarkdown

alt text

Chunk Options

Option default effect
eval TRUE Evalute the code and include the results
echo TRUE Display the code along with its results
warning TRUE Display warnings
error FALSE Display errors
message TRUE Display messages
tidy FALSE Reformat code to make it ‘tidy’
results “markup” “markup”, “asis”,“hold”,“hide”
cache FALSE Cache results for future renders
comment "##" Comment character to preface results
fig.width 7 Width in inches for plots
fig.height 7 Height in inches for plots

RMarkdown

alt text

Code Chunks

All R code to be run must be in a code chunk like this:

#```{r,eval=F}
CODE HERE
#```

Chunk examples

R Code Chunks: Displaying Plots

alt text

Global chunk options

Use chunk options throughout a document: alt text

Easily visualize on GitHub

Update the YAML header to keep the markdown file

From this:

title: "Untitled"
author: "Adam M. Wilson"
date: "September 21, 2015"
output: html_document

To this:

title: "Demo"
author: "Adam M. Wilson"
date: "September 21, 2015"
output: 
  html_document:
      keep_md: true

And click knit HTML to generate the output

Explore markdown functions

  1. Use File -> New File -> R Markdown to create a new markdown file.
  2. Use the Cheatsheet to add sections (# and ##) and some example narrative.
  3. Try changing changing the species name to your favorite species and re-run the report.
  4. Stage, Commit, Push!
  5. Explore the markdown file on the GitHub website.

Colophon

Licensing: * Presentation: CC-BY-3.0 * Source code: MIT

References

See Rmd file for full references and sources